package com.example.tse.rbhttpservice.service.member;


import android.content.Context;

import com.example.tse.rbhttpservice.service.HttpService;
import com.example.tse.rbhttpservice.service.RemoteServiceListenerT;
import com.example.tse.rbhttpservice.service.ResponseServiceListenerT;
import com.example.tse.rbhttpservice.service.RudderResponse;
import com.example.tse.rbhttpservice.service.member.model.MemberFeedbackAddRequest;
import com.example.tse.rbhttpservice.service.member.model.MemberFeedbackAddResponse;
import com.google.gson.Gson;

import org.kymjs.kjframe.http.HttpParams;





/**
 * 
 * @author wliu
 *    edi  tse
 */
public class MemberFeedbackServiceImpl implements MemberFeedbackService {
	private Context context;
	private static Gson gson = new Gson();
	
	
	public MemberFeedbackServiceImpl(Context context) {
		this.context = context;
	}
	/**
	 * 添加意见反馈内容，140字以内
	 * @param request
	 * @param listener
	 * @return MemberFeedbackAddResponse
	 */		
	 
	    public void add(MemberFeedbackAddRequest request, final RemoteServiceListenerT<MemberFeedbackAddResponse> listener) {

        final HttpParams params = new HttpParams();
        

            params.put("content",request.getContent());

        final String url = "member/feedback/add";


            new HttpService().post(context, url, params, MemberFeedbackAddResponse.class, new ResponseServiceListenerT<RudderResponse>() {

            @Override
            public void onPreStart() {
                super.onPreStart();
                listener.PreStart();
            }

            public void ok(RudderResponse rudderResponse) {
                super.ok(rudderResponse);
                listener.ok((MemberFeedbackAddResponse) rudderResponse);
            }

            @Override
            public void okData(RudderResponse rudderResponse) {
                super.okData(rudderResponse);
                listener.okData(rudderResponse == null ? new MemberFeedbackAddResponse() : (MemberFeedbackAddResponse) rudderResponse);
            }

            @Override
            public void okData(RudderResponse rudderResponse, int fromWhere) {
                super.okData(rudderResponse, fromWhere);
                listener.okData(rudderResponse == null ? new MemberFeedbackAddResponse() : (MemberFeedbackAddResponse) rudderResponse, fromWhere);
            }

            @Override
            public void onFailure(int errorNo, String strMsg) {
                super.onFailure(errorNo, strMsg);
                listener.failue(errorNo, strMsg);
            }

            @Override
            public void onFinish() {
                super.onFinish();
                listener.Finish();
            }
        });
    }

   
	
	
}